﻿using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using YogaStudio.Data;
using YogaStudio.Data.Domain;

namespace YogaStudio.Service.BLL
{
   public class RoomService : IRoomService
   {

       private YogaStudioEntities db;

       public RoomService()
       {
           db = new YogaStudioEntities(); 
       }
        public List<Room> GetAllRooms()
        {
            return db.Rooms.ToList();
        }
        public Room GetRoom(int? id)
        {
            return db.Rooms.Find(id);

        }
        public bool DeleteRoom(Room room)
        {
            if (room == db.Rooms.Remove(room))
                db.SaveChanges();

                return true;

        }
        public void UpdateRoom(Room room)
        {
            db.Entry(room).State = EntityState.Modified;
            db.SaveChanges();
        }
        public void SaveRoom(Room room)
        {
            db.Rooms.Add(room);
            db.SaveChanges();
        }
        public void Dispose(bool disposing)
        {
            if (disposing) db.Dispose();
        }
    }
}
